Skip to content

Conversation

@Verma-Anukul
Copy link
Contributor

@Verma-Anukul Verma-Anukul commented May 8, 2025

This change is to provide a way to run go tests present in sonic-mgmt-common locally in dev environment

~buildimage-compilation/sonic-buildimage/src/sonic-mgmt-common > make -f makefile.test

cp ~/buildimage-compilation/sonic-buildimage/src/sonic-mgmt-common/../../target/debs/bookworm//libyang_1.0.73_amd64.deb test/bookworm
cp ~/buildimage-compilation/sonic-buildima
ge/src/sonic-mgmt-common/../../target/debs/bookworm//libyang-dev_1.0.73_amd64.deb test/bookworm
cp ~/buildimage-compilation/sonic-buildima
ge/src/sonic-mgmt-common/../../target/debs/bookworm//libyang-dbgsym_1.0.73_amd64.deb test/bookworm
cp ~/buildimage-compilation/sonic-buildima
ge/src/sonic-mgmt-common/../../target/debs/bookworm//libyang-cpp_1.0.73_amd64.deb test/bookworm
cp ~/buildimage-compilation/sonic-buildima
ge/src/sonic-mgmt-common/../../target/python-wheels/bookworm//sonic_yang_models-1.0-py3-none-any.whl
test/bookworm
docker build --build-arg no_proxy=.cisco.com,.webex.com,localhost,127.0.0.1,10.0.0.0/8,172.16.0.0/12,
192.168.0.0/16
....

PASS
coverage: 42.5% of statements in ../translib/transformer

  • generate_html_report coverage.transformer
  • /usr/local/go/bin/go tool cover -html=coverage.transformer -o .//coverage.transformer.html
  • popd
    ~/buildimage-compilation/sonic-buildimage/src/sonic-mgmt-common
  • exit 0

@mssonicbld
Copy link

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Verma-Anukul
Copy link
Contributor Author

@kwangsuk @anand-kumar-subramanian @mbalachandar @amrutasali @sachinholla @sneelam20

Please help in review and merge

@sachinholla
Copy link
Contributor

We typically use make cvl-test and tools/test/translib-test.sh scripts to run the tests locally. Have you used them?

.idea
test/bookworm/*.deb
test/bookworm/*.whl
container
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible generate all outputs under build directory?

#

ifneq ($(SONIC_YANG_IMPORTS),)
SONICYANG_IMPORTS = $(shell echo $(SONIC_YANG_IMPORTS))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What values will be passed through SONIC_YANG_IMPORTS variable?? I don't see any usage.. Also, $(shell echo $(SONIC_YANG_IMPORTS)) will be same as $(SONIC_YANG_IMPORTS)


OUTPUT_DIR=./
DETAILED_COV=n
SKIP_BUILD=n
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see DETAILED_COV and SKIP_BUILD used anywhere. Is this an incomplete script?

pushd build/tests/cvl
CVL_SCHEMA_PATH=testdata/schema \
./cvl.test -test.v -alsologtostderr -test.coverprofile coverage.cvl || STATUS=1
generate_html_report coverage.cvl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these coverage files will be generated under repo root, right? I don't think there is any cleanup step. Better to use some subdirectory under build directory as OUTPUT_DIR

./transformer.test -test.v -alsologtostderr -test.coverprofile coverage.transformer || STATUS=5
generate_html_report coverage.transformer
popd
exit ${STATUS}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this script to test or tools/test directory?
Also, the content looks duplicate of steps in azure-pipelines.yml file. Can the pipeline sanity step just invoke this script?

@@ -0,0 +1,80 @@
#!/bin/bash -x

# Run sanity tests for sonic-mgmt-common.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this to run tests locally on the development server? If yes please explore the tools/test/translib-test.sh script as well. You can execute gotests without compiling a test binary.

@mssonicbld
Copy link

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Verma-Anukul Verma-Anukul deleted the infra-to-run-go-test-locally branch October 29, 2025 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants